/*
 * XAboutBox.java, created on Oct 20, 2005
 * 
 * Copyright (c) 2005 - 2007
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.xfc.dialog;

import java.awt.Color;
import java.awt.Frame;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.Icon;
import javax.swing.JLabel;
import javax.swing.JPanel;

import org.xfc.XApp;

import com.jgoodies.forms.layout.FormLayout;

/**
 *
 *
 * @author Devon Carew
 */
public class XAboutBox
	extends XDialog
{
	private Icon 	image;
	private String 	text;
	
	/**
	 * 
	 */
	public XAboutBox()
	{
		this(XApp.getApp().getActiveAppFrame());
	}

	/**
	 * @param parent
	 */
	public XAboutBox(Frame parent)
	{
		super(parent);
		
		setOKAction(createDefaultCloseAction());
		
		// TODO: I18N
		setTitle("About");
	}
	
	public JPanel getContents()
	{
		JPanel panel = new JPanel(new FormLayout(
			"pref, pref, pref:grow", 
			"pref"
		));
		
		if (getImage() != null)
		{
			JLabel label = new JLabel(getImage());
			label.setBorder(BorderFactory.createLineBorder(Color.BLACK));
			panel.add(label, "1, 1, l, t");
		}
		
		if (getImage() != null && getText() != null)
		{
			panel.add(Box.createHorizontalStrut(10), "2, 1");
		}
		
		if (getText() != null)
		{
			panel.add(new JLabel(getText()), "3, 1, l, t");
		}
		
		return panel;
	}

	/**
	 * @return Returns the image.
	 */
	public Icon getImage()
	{
		return image;
	}

	/**
	 * @param image The image to set.
	 */
	public void setImage(Icon image)
	{
		this.image = image;
	}

	/**
	 * @return Returns the text.
	 */
	public String getText()
	{
		return text;
	}

	/**
	 * @param text The text to set.
	 */
	public void setText(String text)
	{
		this.text = text;
	}
	
}
